<article class="" id="post-">
<header class="entry-header">
<h1 class="entry-title">jQuery.ready</h1>
<div class="entry-meta">
						所属分类：<span class="category"><a href="/category/core/">核心 API</a></span><span class="category-divider"> | </span><span class="category"><a href="/category/properties/">内部属性</a> &gt; <a href="/category/properties/global-jquery-object-properties/">全局 jQuery 对象的属性</a></span><span class="category-divider"> | </span><span class="category"><a href="/category/events/">事件</a> &gt; <a href="/category/events/document-loading/">文档加载</a></span>
<span class="pull-right">英文文档：<a href="https://api.jquery123.com/jQuery.ready/" target="_blank">jQuery.ready</a></span>
</div><!-- .entry-meta -->
</header><!-- .entry-header -->
<article class="entry property" id="jQuery-ready1"><h2 class="section-title">
<span>jQuery.ready</span><span class="returns">Returns: <a href="http://api.jquery.com/Types/#Thenable">Thenable</a></span>
</h2>
<div class="entry-wrapper">
<p class="desc"><strong>Description: </strong>A Promise-like object (or "thenable") that resolves when the document is ready.</p>
<ul class="signatures"><li class="signature"><h4 class="name">
<span class="version-details">version added: <a href="/category/version/1.8/">1.8</a></span>jQuery.ready</h4></li></ul>
<div class="longdesc" id="entry-longdesc">
<p>As of jQuery 3.0, use of this object is supported via <code><a href="/jQuery.when/">jQuery.when</a></code> or the native <code>Promise.resolve()</code>. Code should not make assumptions about whether this object is a <code>jQuery.Deferred</code>, native Promise, or some other type of promise object.</p>
<p>See also <code><a href="/ready/">ready()</a></code>, which makes use of this.</p>
</div>
<section class="entry-examples" id="entry-examples"><header><h2>Examples:</h2></header><div class="entry-example" id="example-0">
<p>Listen for document ready using <code><a href="/jQuery.when/">jQuery.when</a></code>.</p>
<div class="syntaxhighlighter javascript">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code>$.when( $.ready ).then(<span class="keyword">function</span>() {</code></div></div><div class="container"><div class="line"><code>  <span class="comment">// Document is ready.</span></code></div></div><div class="container"><div class="line"><code>});</code></div></div></pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="entry-example" id="example-1">
<p>Typical usage involving another promise, using <code><a href="/jQuery.when/">jQuery.when</a></code>.</p>
<div class="syntaxhighlighter javascript">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
<div class="line n4">4</div>
<div class="line n5">5</div>
<div class="line n6">6</div>
<div class="line n7">7</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code>$.when(</code></div></div><div class="container"><div class="line"><code>  $.getJSON( <span class="string">"ajax/test.json"</span> ),</code></div></div><div class="container"><div class="line"><code>  $.ready</code></div></div><div class="container"><div class="line"><code>).done(<span class="keyword">function</span>( data ) {</code></div></div><div class="container"><div class="line"><code>  <span class="comment">// Document is ready.</span></code></div></div><div class="container"><div class="line"><code>  <span class="comment">// Value of test.json is passed as `data`.</span></code></div></div><div class="container"><div class="line"><code>});</code></div></div></pre>
</td>
</tr>
</tbody>
</table>
</div>
</div></section>
</div></article>
</article>